<?php
class Discountmall extends BZ_Controller
{
    public function _init()
    {
        $this->load->helper('common');
        $this->load->model('scenery_base_model','scenery_base');
        $this->load->model('tourism_goods_base_model','tourism_goods_base');
        $this->load->model('user_account_model','user_account');
        $this->load->model('provider_guarantee_model','provider_guarantee');
    }

    public function show()
    {
        if ($this->uid) {
            $this->data['account'] = $this->user_account->findByUserAccount($this->uid)->row();
        }
        $params = array('off_bonus' => 1, 'swim' => 1, 'limit' => 16, 'sort' => 2, 'full_bonus' => 1);
        $this->data['tourismListBonus'] = $this->tourism_goods_base->findBzCurrencyTourism($params);

        $this->load->view('home/discountMall/show', $this->data);
    }

    /**
     * 异步刷新景区 和商品
     */
    public function ajaxList()
    {
        $params = array('off_bonus' => 1, 'swim' => 1, 'limit' => 20, 'sort' => 2, 'full_bonus' => 2);
        $data['tourismList'] = $this->tourism_goods_base->findBzCurrencyTourism($params);
        echo json_encode([
            'tourism' => $this->load->view('home/discountMall/ajaxTourism.php', $data, true)
        ]);
        exit;
    }

    /**
     * 金币规则
     */
    public function bonusRule()
    {
        $this->load->view('home/discountMall/bonusRule', $this->data);
    }

    /**
     * 消费保障
     */
    public function protection()
    {
        $this->data['guarantee'] = $this->provider_guarantee->findByParams(['uid' => $this->providerUid]);
        $this->load->view('home/discountMall/protection', $this->data);
    }
}